package org.example.spring_book.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum BookStatusEnum {

    //枚举

    DELETED(0,"删除"),
    NORMAL(1,"可借阅"),
    FORBIDDEN(2,"不可借阅");


    private Integer code;
    private String desc;

    BookStatusEnum(Integer code,String desc){
        this.code=code;
        this.desc=desc;
    }

    public static BookStatusEnum getStatusByCode(Integer code) {
        //lambda
        return Arrays.stream(BookStatusEnum.values()).filter(status -> status.getCode() == code).findFirst().get();
    }

}
